class AI1001 {
    //这是一个行动ai
    constructor() {

    }
    run(node) {
        let role = game.getRole();
        //距离600以外向角色靠近,然后不动
        let dx = role.x - node.x;
        let dy = role.y - node.y;
        let l = dx ** 2 + dy ** 2;//获取长度的**2
        if (dy == 0) {
            dy = 1;
        }
        if (l > 600 ** 2) {
            let angel = Math.atan(dx / dy) * 180 / Math.PI;
            if (dy < 0) {
                angel += 180;
            }
            angel += 10;
            node.x += node.speed * Math.sin(angel * Math.PI / 180);
            node.y += node.speed * Math.cos(angel * Math.PI / 180);
        }
    }

};
module.exports = {
    createAI() {
        return new AI1001;
    }
}